package com.example.exception;

import com.example.permission.UserHaveNotPermissionException;
import com.example.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
@Slf4j
public class PermissionExceptionHandler {

    /**
     * 用户无权限异常
     *
     * @param e 异常
     * @return 错误信息
     */
    @ExceptionHandler(UserHaveNotPermissionException.class)
    public Result noPermissionException(UserHaveNotPermissionException e) {
        return Result.error("无操作权限");
    }
}
